import React, { useState } from 'react'
import B from './B';
//1. 创建 context 对象
export let context = React.createContext();

export default function A() {
  let [count, setCount] = useState(0);
  return (
    <div>
      <h2>A</h2>
      <hr />
      {/* 2. context.Provider 组件包裹后辈组件 */}
      <context.Provider value={[count, setCount]}>
        <B />
      </context.Provider>
    </div>
  )
}
